package com.axend.aerosense.dev.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.axend.aerosense.base.fragment.MvvmBaseFragment;
import com.axend.aerosense.base.viewmodel.BaseViewModel;
import com.axend.aerosense.common.base.ITitle;
import com.axend.aerosense.dev.R;
import com.axend.aerosense.dev.activity.NewDevSetNetActivity;
import com.axend.aerosense.dev.databinding.DevFragmentAddSuccessBinding;

public class DevAddSuccessFragment extends MvvmBaseFragment<DevFragmentAddSuccessBinding, BaseViewModel> {

    public static DevAddSuccessFragment getInstance(){
        return new DevAddSuccessFragment();
    }

    @Override
    public int getLayoutId() {
        return R.layout.dev_fragment_add_success;
    }

    @Override
    public int getBindingVariable() {
        return 0;
    }

    @Override
    protected BaseViewModel getViewModel() {
        return null;
    }

    @Override
    protected void onRetryBtnClick() {

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
    }

    private void initView(){
        //点击下一步，回到主页
        viewDataBinding.devNext.setOnClickListener(v -> getActivity().finish());
    }

    private void goneTitleBarRightText(){
        Activity activity = getActivity();
        if (activity instanceof NewDevSetNetActivity){
            NewDevSetNetActivity newDevSetNetActivity = (NewDevSetNetActivity) activity;
            newDevSetNetActivity.isShowRightText(false,null);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        ((ITitle)getActivity()).setTitle(getString(R.string.dev_added_successfully));
        goneTitleBarRightText();
    }
}
